package prototype.simple;

import java.util.ArrayList;

public class ConcretePrototype implements Cloneable {
    private int age;
    private String name;

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    public ArrayList<String> list = new ArrayList<String>();

    protected Object clone() throws CloneNotSupportedException {
        ConcretePrototype prototype = null;
        try {
            prototype = (ConcretePrototype) super.clone();
            prototype.list = (ArrayList) list.clone();
            //克隆是字节码的
            // list 里面还有list 就要用循环 反射
        } catch (Exception e) {

            e.printStackTrace();
        }
        return prototype;
    }

}
